﻿using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;

namespace Yoozoo.Gameplay.Liberty.AI.Node
{
    [Category("Ggame/Liberty")]
    public class NpcTriggerGrenadeReloadAnimation : AIBaseNode
    {
        protected override void OnExecute()
        {
            // 检测自身状态
            AnimationAgent animationAgent = _entity.viewer.animationAgent;
            if (!animationAgent.CanDoNextAnimation())
            {
                EndAction(false);
                return;
            }
            
            // 装弹
            animationAgent.PlayGrenadeReload();
        }

        protected override void OnUpdate()
        {
            if (elapsedTime < 0.1f)
            {
                return;
            }
            
            AnimationAgent animationAgent = _entity.viewer.animationAgent;
            if (animationAgent.CanDoNextAnimation())
            {
                EndAction(true);
            }
        }

        
    }
}